package org.wu.framework.authorization.platform.application.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.wu.framework.authorization.platform.application.SysRoleMenuApplication;
import org.wu.framework.authorization.platform.application.assembler.SysRoleMenuDTOAssembler;
import org.wu.framework.authorization.platform.application.command.SysRoleMenuCommand;
import org.wu.framework.authorization.platform.domain.model.sys.role.menu.SysRoleMenu;
import org.wu.framework.authorization.platform.domain.model.sys.role.menu.SysRoleMenuRepository;
import org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl;
import org.wu.framework.lazy.orm.web.plus.stereotype.LazyApplication;
import org.wu.framework.web.response.Result;

import java.util.List;

/**
 * describe 角色菜单
 *
 * @author Jia wei Wu
 * @date 2023/05/17 11:19 晚上
 * @see DefaultDDDLazyApplicationImpl
 **/
@LazyApplication
public class SysRoleMenuApplicationImpl implements SysRoleMenuApplication {

    @Autowired
    SysRoleMenuRepository sysRoleMenuRepository;

    /**
     * describe 新增角色菜单
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysRoleMenu> save(SysRoleMenuCommand sysRoleMenuCommand) {
        SysRoleMenu sysRoleMenu = SysRoleMenuDTOAssembler.toRoleMenu(sysRoleMenuCommand);
        return sysRoleMenuRepository.story(sysRoleMenu);
    }

    /**
     * describe 更新角色菜单
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysRoleMenu> update(SysRoleMenuCommand sysRoleMenuCommand) {
        SysRoleMenu sysRoleMenu = SysRoleMenuDTOAssembler.toRoleMenu(sysRoleMenuCommand);
        return sysRoleMenuRepository.story(sysRoleMenu);
    }

    /**
     * describe 查询单个角色菜单
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysRoleMenu> findOne(SysRoleMenuCommand sysRoleMenuCommand) {
        SysRoleMenu sysRoleMenu = SysRoleMenuDTOAssembler.toRoleMenu(sysRoleMenuCommand);
        return sysRoleMenuRepository.findOne(sysRoleMenu);
    }

    /**
     * describe 查询多个角色菜单
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<List<SysRoleMenu>> findList(SysRoleMenuCommand sysRoleMenuCommand) {
        SysRoleMenu sysRoleMenu = SysRoleMenuDTOAssembler.toRoleMenu(sysRoleMenuCommand);
        return sysRoleMenuRepository.findList(sysRoleMenu);
    }

    /**
     * describe 删除角色菜单
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysRoleMenu> delete(SysRoleMenuCommand sysRoleMenuCommand) {
        SysRoleMenu sysRoleMenu = SysRoleMenuDTOAssembler.toRoleMenu(sysRoleMenuCommand);
        return sysRoleMenuRepository.remove(sysRoleMenu);
    }

}